import traci


class TrafficLight:
    def __init__(self, tl_id):
        self.tl_id = tl_id
        self._states_index = traci.trafficlight.getPhase(self.tl_id)
        self._durations = traci.trafficlight.getNextSwitch(self.tl_id) - traci.simulation.getTime()

    def update_info(self):
        self._states_index = traci.trafficlight.getPhase(self.tl_id)
        self._durations = traci.trafficlight.getNextSwitch(self.tl_id) - traci.simulation.getTime()

    def get_tl_id(self):
        return self.tl_id

    def get_states(self):
        return self._states_index

    def get_durations(self):
        return self._durations

